package com.hqd.ch03.v25.config;

import com.hqd.ch03.v25.factory.ConfigurableBeanFactory;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
public class BeanDefinition {
    private String id;
    private String beanClass;
    private String scope;
    private Boolean lazyInit;
    private String initMethodName;
    private String destroyMethodName;
    private String description;
    /**
     * 是否合成的，为框架内部使用，比如说aop部分
     */
    private boolean synthetic = false;
    private MutablePropertyValues properties = new MutablePropertyValues();
    private ConstructorArgumentValues constructorArgumentValues;
    private String SCOPE_SINGLETON = ConfigurableBeanFactory.SCOPE_SINGLETON;
    private String SCOPE_PROTOTYPE = ConfigurableBeanFactory.SCOPE_PROTOTYPE;

    public BeanDefinition() {

    }

    public BeanDefinition(Class<?> clazz) {
        this.beanClass = clazz.getName();
    }

    public boolean isSingleton() {
        return StringUtils.equalsIgnoreCase(SCOPE_SINGLETON, scope);
    }

    public boolean isPrototype() {
        return StringUtils.equalsIgnoreCase(SCOPE_PROTOTYPE, scope);
    }

    public MutablePropertyValues getPropertyValues() {
        return properties;
    }

    public boolean isSynthetic() {
        return synthetic;
    }

    public void setSynthetic(boolean synthetic) {
        this.synthetic = synthetic;
    }
}
